//
//  VisitorLoginView.swift
//  Status
//
//  Created by 花轮 on 15/5/10.
//  Copyright (c) 2015年 花轮. All rights reserved.
//

import UIKit

protocol VisitorLoginViewDelegate : NSObjectProtocol
{
    func visitorViewLoginBtnDidCilck(VisitorLoginView)
    func visitorViewRegisterBtnDidCilck(VisitorLoginView)
}


class VisitorLoginView: UIView {
    @IBOutlet weak var attractText: UILabel!
    @IBOutlet weak var animateImage: UIImageView!
    @IBOutlet weak var centerImage: UIImageView!
    
    weak var delegate: VisitorLoginViewDelegate?
    
    func setupInfo(imageName: String, descText: String, isHome: Bool = false)
    {
        centerImage.hidden = !isHome
        
        
        if isHome
        {
            centerImage.image = UIImage(named: imageName)
            startAnimation()
        }
        else
        {
            animateImage.image = UIImage(named: imageName)
        }
        
        attractText.text = descText
    }
    
    func startAnimation()
    {
        let anim = CABasicAnimation(keyPath: "transform.rotation")
        
        anim.toValue = 2 * M_PI
        anim.repeatCount = MAXFLOAT
        anim.duration = 35
        
        animateImage.layer.addAnimation(anim, forKey: nil)
    }
   
    @IBAction func registerClick() {
        delegate?.visitorViewRegisterBtnDidCilck(self)
    }
    @IBAction func loginClick() {
        delegate?.visitorViewLoginBtnDidCilck(self)
    }
}
